const app = {
  state: {
    // 应用是否已经登录
    isLogin: false
  },

  mutations: {
    SET_IS_LOGIN: (state, value) => {
      state.isLogin = value
    }
  },

  actions: {
    InitApp({
      commit,
      rootState
    }) {
      const isLogin = uni.getStorageSync('is_login')
      if (isLogin === true) {
        commit('SET_IS_LOGIN', isLogin)
        const userInfo = uni.getStorageSync('user_info')
        const {
          token,
          email
        } = userInfo
        commit('SET_TOKEN', token, {
          root: true
        })
        commit('SET_EMAIL', email, {
          root: true
        })
      }
    }
  }
}

export default app